def evaluate(r1: str) -> int:
    sum1 = 0
    for index, ch1 in enumerate(r1):
        if ch1 != "+" and ch1 != "-":
            znak = r1[index-1]
            if znak == "+":
                sum1 += int(ch1)
            elif znak == "-":
                sum1 -= int(ch1)
            else:
                sum1 = int(ch1)
    print(sum1)
    return sum1


assert evaluate("1+2-3") == 0
assert evaluate("1+2-3+9+7+3-8-1-1-1-5") == 3